import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'list.dart';

/**
 * 登录表单
 */
class HomePage extends StatefulWidget {
  @override
  _LoginPageState createState() => _LoginPageState();
}

class _LoginPageState extends State<HomePage> {
  bool _agreed = false;

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
        length: 3,
        child: Scaffold(
            appBar: AppBar(
              title: Text("定 制 公 交"),
            ),
            body: Container(
              padding: EdgeInsets.all(5),
              decoration: BoxDecoration(
                image: DecorationImage(
                  image: AssetImage("images/ai2.jpg"),
                  fit: BoxFit.cover,
                ),
              ),
              child: Center(
                child: Form(
                  child: Center(
                    child: Column(
                      children: [
                        TextFormField(
                          inputFormatters: [
                            FilteringTextInputFormatter.digitsOnly
                          ],
                          decoration: InputDecoration(
                              icon: Icon(Icons.phone_android),
                              hintText: "请输入手机号码"),
                        ),
                        SizedBox(height: 20),
                        // 验证码输入
                        Row(
                          children: [
                            Expanded(
                              child: TextField(
                                inputFormatters: [
                                  FilteringTextInputFormatter.digitsOnly
                                ],
                                decoration: InputDecoration(
                                  labelText: '验证码',
                                  prefixIcon: Icon(Icons.code),
                                ),
                              ),
                            ),
                            SizedBox(width: 10),
                            ElevatedButton(
                              onPressed: () {},
                              child: Text('获取验证码'),
                            ),
                          ],
                        ),
                        SizedBox(height: 20),
                        // 同意条款
                        Row(
                          children: [
                            Checkbox(
                              value: _agreed,
                              onChanged: (v) => setState(
                                  () => _agreed = v ?? false), // 处理null情况
                            ),
                            Text('同意条款'),
                          ],
                        ),
                        SizedBox(height: 20),
                        ElevatedButton(
                          onPressed: () => {
                            Navigator.push(context,
                                MaterialPageRoute(builder: (context) => List()))
                          },
                          child: Text("登录"),
                        ),
                      ],
                    ),
                  ),
                ),
              ),
            ),
            bottomNavigationBar: Container(
              child: TabBar(
                labelStyle: TextStyle(height: 0,fontSize: 10),
                tabs: [
                  Tab(
                    icon: Icon(Icons.filter_vintage_rounded),
                    text: "引导",
                  ),
                  Tab(
                    icon: Icon(Icons.home),
                    text: "主页",
                  ),
                  Tab(
                    icon: Icon(Icons.person),
                    text: "我的",
                  ),
                ],
              ),
              decoration: BoxDecoration(
                color: Colors.black,
              ),
              height: 50,
            )));
  }
}
